﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DatabaseComponent
{
    public class GlobalThings
    {





        public static string getWhereWithoutDeleted(string strWhere)
        {

            if (strWhere.Equals(String.Empty))
                return " where [StatusID] <> '2' ";



            string strOrder = "";


            if (strWhere.ToLower().Contains("order by"))
            {
                int orderindex = strWhere.ToLower().IndexOf("order by");

                strOrder = strWhere.Substring(orderindex);


                if (orderindex == 0)
                    strWhere = "";
                else
                    strWhere = strWhere.Substring(0, orderindex);
            }
            else
            {
                strOrder = "";
            }


            if (strWhere.Trim().Equals(String.Empty))
                return " where [StatusID] <> '2' " + strOrder;


            if (strWhere.ToLower().Contains("where"))
            {
                int whereindex = strWhere.ToLower().IndexOf("where");
                strWhere = strWhere.Substring(whereindex + 5);

                return " where ([StatusID] <> '2') AND (" + strWhere + ") " + strOrder;

            }
            else
            {
                return " where [StatusID] <> '2' " + strOrder;
            }









        }


    }

}
